package com.moyuxi.sound_of_the_forest.ui.pages

import android.content.pm.PackageManager
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.moyuxi.sound_of_the_forest.R


@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutMeScreen(
    mainNC: NavController
) {
    Column(
        modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally
    ) {    // 标题栏
        CenterAlignedTopAppBar(
            title = { Text(text = "关于") },
            navigationIcon = {
                Icon(Icons.Default.ArrowBack,
                    "返回",
                    modifier = Modifier
                        .size(36.dp)
                        .clickable { mainNC.popBackStack() })
            })
        Column(
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            Image(
                painterResource(id = R.drawable.logo),
                "头图",
                Modifier
                    .fillMaxWidth()
//                    .background(Color.Transparent)
                    .height(250.dp),
                Alignment.Center,
                ContentScale.FillWidth,
            )
            Text(text = "作者：MoYuXi", fontSize = 24.sp)
            val context = LocalContext.current

            val versionName = context.packageManager.getPackageInfo(
                context.packageName, PackageManager.GET_CONFIGURATIONS
            ).versionName
            Text(text = "Version：${versionName}", fontSize = 24.sp)
        }
        Column {
            val modifier = Modifier.padding(5.dp)
            Text(text = "应用介绍", fontSize = 18.sp, modifier = modifier)
            Spacer(
                modifier = Modifier
                    .height(1.dp)
                    .fillMaxWidth()
//                    .background(MaterialTheme.colorScheme.onBackground)
            )
            Text(
                text = "\u3000\u3000双木林，口鸟鸣，鸟于林中鸣。图的一种放松安逸的氛围。目前还是一款不成熟的本地音乐播放器。更多功能等待继续开发中……",
                fontSize = 15.sp,
                modifier = modifier
            )
        }
    }
}